#pragma once

template<class Iterator, class Ref, class Ptr>
struct __Reverse_Iterator
{
	typedef __Reverse_Iterator<Iterator, Ref, Ptr> Self;

	__Reverse_Iterator(const Iterator& it)
		:_it(it)
	{ }

	Ref operator*()
	{
		Iterator temp(_it);
		return *(--temp);
	}

	Ptr operator->()
	{
		return &(operator*());
	}

	Iterator operator++()
	{
		return --_it;
	}

	Iterator operator++(int)
	{
		Iterator temp = _it;
		--_it;
		return temp;
	}

	Iterator operator--()
	{
		return ++_it;
	}

	Iterator operator--(int)
	{
		Iterator temp = _it;
		++_it;
		return temp;
	}

	bool operator!=(const Self& s)
	{
		return _it != s._it;
	}

	bool operator==(const Self& s)
	{
		return _it == s._it;
	}

	Iterator _it;
};